<?php
namespace App\Http\Middleware;

use App\Http\Controllers\LoginController;

class CheckLogin
{
    public function handle($request, \Closure $next){
        // 判断是否登录
        if (!session('username')){
            // 去登录重定向到登录页
            return redirect()->action([LoginController::class, 'index']);
        }
        return $next($request);
    }
}
